//
//  PCDApiPreviewImage.m
//  PCDMPaasBank
//
//  Created by DK on 2021/3/8.
//  Copyright © 2021 Alibaba. All rights reserved.
//

#import "PCDApiPreviewImage.h"
#import "YBImageBrowser.h"
#import "YBIBVideoData.h"

@interface PCDApiPreviewImage ()
@property(nonatomic,retain) PCDContext *apiContext;
@end

@implementation PCDApiPreviewImage

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback
{
      
    
    self.apiContext = context;
    
    NSArray *urls = [data objectForKey:@"urls"];
    NSString *current = [data objectForKey:@"current"];
    [self showImageWithUrls:urls current:current];
}

- (void)showImageWithUrls:(NSArray *)urls current:(NSString *)current {

    NSMutableArray *datas = [NSMutableArray array];
    [urls enumerateObjectsUsingBlock:^(NSString *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        // 网络图片
        YBIBImageData *data = [YBIBImageData new];
        data.imageURL = [NSURL URLWithString:obj];
//        data.projectiveView = [self viewAtIndex:idx];
        [datas addObject:data];
    }];
    
    
    YBImageBrowser *browser = [YBImageBrowser new];
    browser.dataSourceArray = datas;
    browser.currentPage = 0;
    // 只有一个保存操作的时候，可以直接右上角显示保存按钮
    browser.defaultToolViewHandler.topView.operationType = YBIBTopViewOperationTypeSave;
    [browser show];
}


@end
